﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aurora.Module.Contexts
{
    /// <summary>
    /// service configure context
    /// </summary>
    public class ServiceConfigurationContext
    {
        /// <summary>
        /// services
        /// </summary>
        public IServiceCollection Services { get; }
        /// <summary>
        /// items
        /// </summary>
        public IDictionary<string, object?> Items { get; }

        public object? this[string key]
        {
            get => Items.TryGetValue(key, out var obj) ? obj : default;
        }

        /// <summary>
        /// 构造函数 初始化
        /// </summary>
        /// <param name="services"></param>
        /// <exception cref="ArgumentNullException"></exception>

        public ServiceConfigurationContext([NotNull] IServiceCollection services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            Services = services;
            Items = new Dictionary<string, object?>();
        }
    }
}
